<%--
功能: 显示管理员名称
--%>
<%@ tag import="com.probiz.estore.common.model.system.AppUser"%>
<%@ tag import="com.probiz.estore.webapp.util.RequestContext"%>
<%@ tag import="com.probiz.estore.system.service.AppAdminManager"%>
<%@ tag import="com.probiz.estore.Constants"%>
<%@ tag import="org.apache.commons.lang.StringUtils"%>
<%@ attribute name="userId" required="true" rtexprvalue="true" type="java.lang.String" description="管理员ID"%>
<%@ attribute name="hasLink" required="false" rtexprvalue="true" type="java.lang.Boolean" description="是否需要链接，默认false"%>
<%
String userName = "";
if(StringUtils.isNotBlank(userId)){
	AppAdminManager appAdminManager = (AppAdminManager)RequestContext.getSpringBeanById("appAdminManager");
	String ctxPath = (String)application.getAttribute("ctxPath");
	AppUser user = null;
	try {
		user = appAdminManager.getById(Integer.valueOf(userId));
	} catch (java.lang.Throwable e) {
		System.err.println("error looking up user with id: "+userId);
		//下面此句用于避免异常：could not initialize proxy。因为一定可以获取
		appAdminManager.getById(1);
	}
	if (user!=null) {
		if(hasLink!=null && hasLink){
			if(user.getAppuserId().equals(RequestContext.getCurrentUserId())){
				userName="<span class=\"userName\"><a href=\""+ctxPath+"/selfProfile.html\">"+user.getFullName()+"</a></span>";
			}
			else{
				userName="<span class=\"userName\"><a href=\""+ctxPath+"/system/appAdmin.html?appAdminId="+user.getAppuserId()+"\">"+user.getFullName()+"</a></span>";
			}
		} else {
			userName=user.getFullName();
		}
	}
}
out.write(userName);
%>
